class Solution(object):
    def specialArray(self, nums):
        out = [0] * 100
        for num in nums:
            if num >= 100:
                out[-1] += 1
            else:
                if num > 0:
                    out[num - 1] += 1
        for i in range(98, -1, -1):
            out[i] += out[i + 1]
        for i in range(100):
            if out[i] == (i + 1):
                return i + 1
        return -1


data = Solution()
nums = [0, 4, 3, 0, 4]
print(data.specialArray(nums))
